<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>童装试穿详情</title>
    <link rel="stylesheet" href="">
    <link rel="stylesheet" href="/main/css/style.css">
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
</head>
<body>
<!--fixed remove-->
<section class="fixed" style="z-index:999;width: 100%;height: 100%;background-color: #000;position: fixed;left: 0;top: 0;"></section>
<section class="detail_page">
    <div><img src="/main/img/detail_two_01.jpg" width="100%" height="auto"></div>
    <div>{%$content|default:''%}</div>
    <div class="product_param">
        <p class="title">服装尺寸选择</p>
        <p class="sub_title">{%$clothing_name|default:''%}</p>
        <dl>
            <dt>颜色分类</dt>
            {%if $color|@count neq 0 %}
            {%foreach $color as $colorkey=>$colorvalue%}
            <dd colorid="{%$colorvalue.id%}" onclick="setcolor(this)">{%$colorvalue.colorname%}</dd>
            {%/foreach%}
            {%/if%}

        </dl>
        <dl class="height">
            <dt>参考身高</dt>
            {%if $size|@count neq 0 %}
            {%foreach $size as $sizekey=>$sizevalue%}
            <dd sizeid="{%$sizevalue.id%}"  onclick="setsize(this)">{%$sizevalue.sizename%}</dd>
            {%/foreach%}
            {%/if%}

        </dl>
        <div class="tao_token">
            <p>复制以下淘口令，打开淘宝APP直接购买吧</p>
            <span class="command">{%$tkcode|default:''%}</span>
        </div>

        {%if $user.intergtal >= $integral%}
        {%if $joinnum < $num %}
        <span class="tj_btn" onclick="dosub()">{%$integral|default:''%}积分兑换</span>
        {%else%}
        <span class="tj_btn gray_btn">兑换结束</span>
        {%/if%}
        {%else%}
        <span class="tj_btn gray_btn"> {%$integral|default:''%}积分兑换</span>
        {%/if%}

    </div>
    </div>
</section>
</body>
<script src="/main/js/jquery-1.12.3.min.js"></script>
<script src="/main/js/common.js"></script>
<script>

    var colorid=0;
    var sizeid=0;
    $(window).load(function () {
        checkweichatevent();
        touchEvent();
        $(".product_param dl dd").on('click',function () {
            $(this).addClass('current').siblings().removeClass('current');
        })
    });
    function setcolor(obj) {
        colorid=parseInt(obj.getAttribute('colorid'));
    }
    function setsize(obj) {
        sizeid=parseInt(obj.getAttribute('sizeid'));
    }
    function dosub() {
        if(colorid==0){
            alert('请选择颜色');return false;
        }
        if(sizeid==0){
            alert('请选择尺码');return false;
        }
        $.ajax({
                type: "POST",
                url: "/api/doclothing.json",
                data: {id: {%$id|default:0%},colorid: colorid, sizeid: sizeid, tk_name: "{%$tk_name%}", tk_value: "{%$tk_value%}"},
                success:function (data) {
                    alert('兑换成功');
                    refulsh();
           },
        error:function(){
            alert('兑换失败')
        }

    })

    }
</script>
</html>